home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d1 / freemacs.arc / PICK.ASM < prev    next >
Assembly Source File  |  1988-03-17  |  3KB  |  169 lines

  1.     page    ,132
  2.  
  3.     .xlist
  4.     include    mintdefs.asm
  5.  
  6. data    segment byte public
  7. mouse_flag    db    ?
  8.     extrn    scan_lines_per_char: byte
  9. data    ends
  10.  
  11. code    segment byte public
  12.  
  13.     assume cs:code, ds: data, es: data
  14.  
  15.     public    pick_init, pick_on, pick_off, check_pick, get_pick_values
  16. pick_init:
  17.     call    mouse_exists
  18.     mov    ax,0
  19.     int    33h
  20.     mov    mouse_flag,al        ;remember if the mouse exists.
  21.     mov    ax,4            ;move the mouse to the upper right hand.
  22.     mov    cx,635
  23.     mov    dx,0
  24.     int    33h
  25.     mov    ax,10            ;set text cursor (ignored on Z-100).
  26.     mov    bx,0            ;software text cursor.
  27.     mov    cx,77ffh        ;screen mask
  28.     mov    dx,7700h        ;cursor mask
  29.     int    33h
  30.     call    check_pick        ;ensure that there are no up or down
  31.     call    check_pick        ;  events left.
  32.     call    check_pick
  33.     call    check_pick
  34.     ret
  35.  
  36.  
  37. pick_on:
  38.     call    mouse_exists
  39.     mov    ax,1
  40.     int    33h
  41.     ret
  42.  
  43.  
  44. pick_off:
  45.     call    mouse_exists
  46.     mov    ax,1            ;ensure that we work with MOUSEKEY.
  47.     int    33h
  48.     mov    ax,2
  49.     int    33h
  50.     ret
  51.  
  52.  
  53. check_pick:
  54. ;return nz and al=pick character.  return zr if no pick.
  55.     call    mouse_exists
  56.     push    bx
  57.     push    cx
  58.     push    dx
  59.     cmp    mouse_flag,0        ;inhibit mouse presses if it isn't there.
  60.     je    check_pick_1
  61.     mov    ax,5
  62.     mov    bx,0            ;left button press
  63.     int    33h
  64.     mov    ax,0feh
  65.     or    bx,bx
  66.     jne    check_pick_1
  67.     mov    ax,5            ;right button press
  68.     mov    bx,1
  69.     int    33h
  70.     mov    ax,0fdh
  71.     or    bx,bx
  72.     jne    check_pick_1
  73.     mov    ax,5            ;middle button press
  74.     mov    bx,2
  75.     int    33h
  76.     mov    ax,0fah
  77.     or    bx,bx
  78.     jne    check_pick_1
  79.     mov    ax,6            ;left button release
  80.     mov    bx,0
  81.     int    33h
  82.     mov    ax,0fch
  83.     or    bx,bx
  84.     jne    check_pick_1
  85.     mov    ax,6            ;right button release
  86.     mov    bx,1
  87.     int    33h
  88.     mov    ax,0fbh
  89.     or    bx,bx
  90.     jne    check_pick_1
  91.     mov    ax,6            ;middle button release
  92.     mov    bx,2
  93.     int    33h
  94.     mov    ax,0f9h
  95.     or    bx,bx
  96.     jne    check_pick_1
  97. check_pick_1:
  98.     pop    dx
  99.     pop    cx
  100.     pop    bx
  101.     ret
  102.  
  103. get_pick_values:
  104.     mov    cx,0
  105.     mov    dx,0
  106.     call    mouse_exists
  107.     mov    ax,3
  108.     int    33h
  109.  
  110.     push    cx            ;save the x value.
  111.  
  112.     mov    ax,dx
  113.     div    scan_lines_per_char
  114.     mov    ah,0
  115.     push    ax
  116.     call    read_linesbefore
  117.     push    ax
  118.     call    read_newrow
  119.     pop    bx
  120.     sub    bx,ax            ;bx=linesbefore - newrow.
  121.     pop    dx
  122.     add    dx,bx            ;add y-value.
  123.     inc    dx            ;ax= y-value - newrow + linesbefore + 1.
  124.     pop    ax            ;compute the x-value.
  125.  
  126.     push    dx
  127.  
  128.     mov    cl,8
  129.     div    cl
  130.     mov    ah,0
  131.     inc    ax
  132.     push    ax            ;add in firstcolumn.
  133.     call    read_firstcolumn
  134.     pop    cx
  135.     add    cx,ax
  136.  
  137.     pop    dx
  138.  
  139.     ret
  140.  
  141.     extrn    read_firstcolumn: near
  142.     extrn    read_linesbefore: near
  143.     extrn    read_newrow: near
  144.  
  145.  
  146. ;this routine returns from the routine that called it if the mouse is not
  147. ;  installed.
  148. mouse_exists:
  149.     push    ds
  150.     xor    ax,ax
  151.     mov    ds,ax
  152.     mov    ax,word ptr ds:[33h*4+2]
  153.     pop    ds
  154.     cmp    ax,0            ;any mouse interrupt at all?
  155.     je    mouse_exists_2        ;no - no mouse.
  156.     cmp    ax,40h            ;is the mouse interrupt in the bios?
  157.     jne    mouse_exists_1        ;no - must be a real mouse.
  158. mouse_exists_2:
  159.     add    sp,2
  160.     xor    ax,ax
  161.     ret
  162. mouse_exists_1:
  163.     ret
  164.  
  165. code    ends
  166.  
  167.     end
  168.  
  169.